/* IMF status duration model */

set more off 

use "c:\Data Sets\Africa\africa_1.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b1=e(b)
matrix v1=e(V)
sca ll11=e(ll)

save "c:\Data Sets\Africa\africa_1.dta", replace

use "c:\Data Sets\Africa\africa_2.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b2=e(b)
matrix v2=e(V)
sca ll21=e(ll)

save "c:\Data Sets\Africa\africa_2.dta", replace

use "c:\Data Sets\Africa\africa_3.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b3=e(b)
matrix v3=e(V)
sca ll31=e(ll)

save "c:\Data Sets\Africa\africa_3.dta", replace

use "c:\Data Sets\Africa\africa_4.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b4=e(b)
matrix v4=e(V)
sca ll41=e(ll)

save "c:\Data Sets\Africa\africa_4.dta", replace

use "c:\Data Sets\Africa\africa_5.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b5=e(b)
matrix v5=e(V)
sca ll51=e(ll)

save "c:\Data Sets\Africa\africa_5.dta", replace

use "c:\Data Sets\Africa\africa_6.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b6=e(b)
matrix v6=e(V)
sca ll61=e(ll)

save "c:\Data Sets\Africa\africa_6.dta", replace

use "c:\Data Sets\Africa\africa_7.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

matrix b7=e(b)
matrix v7=e(V)
sca ll71=e(ll)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

save "c:\Data Sets\Africa\africa_7.dta", replace

use "c:\Data Sets\Africa\africa_8.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b8=e(b)
matrix v8=e(V)
sca ll81=e(ll)

save "c:\Data Sets\Africa\africa_8.dta", replace

use "c:\Data Sets\Africa\africa_9.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b9=e(b)
matrix v9=e(V)
sca ll91=e(ll)

save "c:\Data Sets\Africa\africa_9.dta", replace

use "c:\Data Sets\Africa\africa_10.dta", clear
stset imfcount, failure(stattran==1) id(imfid)

streg us_aid quota IMFquota sunfr sunus IMFsunus IMFsunfr franc_ai IMFfraid cfa IMFcfa noncfafr IMFnoncfafr polity anarchy nxtpa_el num_coal pmpty_s  seatlar pfall pcoup cmwlth IMFcmwth IMFpcoup IMFUSA IMFpol IMFanar IMFParl2 IMFnump IMFParts IMFseatl IMFpfall logchdc1 IMFlogchdc1 logchrsL IMFlogchrsL ma5chex IMFma5chex shortter IMFdebt imfstatu, dist(w) cluster(code) 

matrix b10=e(b)
matrix v10=e(V)
sca l211=e(ll)

save "c:\Data Sets\Africa\africa_10.dta", replace

/* Model 1--US influence */

matrix B4=b1\b2\b3\b4\b5\b6\b7\b8\b9\b10
matrix row1=[1,1,1,1,1,1,1,1,1,1]
matrix B4mi=(1/10)*([b1\b2\b3\b4\b5\b6\b7\b8\b9\b10]'*row1')
mat V4mi=(v1+v2+v3+v4+v5+v6+v7+v8+v9+v10)/10
mat Sqs=B4-row1'*B4mi'
mat A=Sqs[1, 1...]
mat AA=diag(A)
mat B=Sqs[2, 1...]
mat BB=diag(B)
mat C=Sqs[3, 1...]
mat CC=diag(C)
mat D=Sqs[4, 1...]
mat DD=diag(D)
mat E=Sqs[5, 1...]
mat EE=diag(E)
mat F=Sqs[6, 1...]
mat FF=diag(F)
mat G=Sqs[7, 1...]
mat GG=diag(G)
mat H=Sqs[8, 1...]
mat HH=diag(H)
mat J=Sqs[9, 1...]
mat JJ=diag(J)
mat K=Sqs[10, 1...]
mat KK=diag(K)

mat Sqsq=[A*AA\B*BB\C*CC\D*DD\E*EE\F*FF\G*GG\H*HH\J*JJ\K*KK]'*row1'

mat SE4sq=vecdiag(V4mi)'+(1/9)*Sqsq*(11/10)
mat SE4mi=(vecdiag(cholesky(diag(SE4sq))))'
mat final1=[B4mi, SE4mi]
mat colnames final1=Coeff StErr
noisily mat list final1

